<?php

class Application_Model_DbTable_Items extends Zend_Db_Table_Abstract
{

    protected $_name = 'items';

    public function getItem($item_no)
    {
    	$item_no = (int)$item_no;
    	$row = $this->fetchRow('item_no = ' . $item_no);
    	if (!$row) {
    		throw new Exception("Could not find row $item_no");
    	}
    	return $row->toArray();
    }
    
	public function addItem($order_no, $prod_no, $item_status, $item_qty, $item_total_price)
	{
		$data = array(
		    				'order_no'=>$order_no,
		    				'prod_no'=>$prod_no,
		    				'item_status'=>$item_status, 
		    				'item_qty'=>$item_qty,
		    				'item_total_price'=>$item_total_price,
		);
		$this->insert($data);
	}    
    
	public function cancelItem($item_no)
	{
   		$cancel = 'C';
   		$data = array(
   	        		'item_status'=> $cancel
   	
   		);
   		$this->update($data, 'item_no = ' . (int)$item_no );
	}
	
	public function cancelorderItem($order_no)
	{
   		$cancel = 'C';
   		$data= array(
   				'item_status'=>$cancel
   				);
   		$this->update($data, 'order_no='.(int)$order_no);
	}
	
	public function deleteItem($item_no)
	{
		
		$this->delete('item_no = '. (int)$item_no);
	}
	
	
}